home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / mach / shortcut.awk < prev    next >
Text File  |  1994-02-07  |  1KB  |  45 lines

  1. # Icky intimate knowledge of MiG output.
  2.  
  3. BEGIN { print "/* This file is generated by shortcut.awk.  */";
  4.     echo=1;
  5.     inproto=0; proto=""; arglist="";
  6.       }
  7.  
  8. $1 == "LINTLIBRARY" { print "#include <mach.h>"; next }
  9.  
  10. # Copy the first line of the definition, but
  11. # replace the function name (RPC) with CALL.
  12. $NF == rpc \
  13.   {
  14.     for (i = 1; i < NF; ++i) printf "%s ", $i;
  15.     print call;
  16.     next;
  17.   }
  18.  
  19. # Collect the lines of the prototype in PROTO, and extract the parameter
  20. # names into ARGLIST.
  21. NF == 1 && $1 == ")" { inproto=0 }
  22. inproto { proto = proto $0;
  23.       arg = $NF;
  24.       gsub(/[^a-zA-Z0-9_,]/, "", arg);
  25.       arglist = arglist arg;
  26.     }
  27. NF == 1 && $1 == "(" { inproto=1 }
  28.  
  29. /^{$/ { echo=0; }
  30.  
  31. echo == 1 { print $0; }
  32.  
  33. /^}$/ \
  34.   {
  35.     print "{";
  36.     print "  kern_return_t err;";
  37.     print "  extern kern_return_t " syscall " (" proto ");";
  38.     print "  err = " syscall " (" arglist ");";
  39.     print "  if (err == MACH_SEND_INTERRUPTED)";
  40.     print "    err = " rpc " (" arglist ");";
  41.     print "  return err;"
  42.     print "}";
  43.     echo = 1;
  44.   }
  45.